package health.lm.com.shop.adapter;

import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import health.lm.com.component_base.helper.ImageLoaderHelper;
import health.lm.com.shop.R;
import health.lm.com.shop.entity.HLAllCompanyEntity;

/**
 * Created by Android Studio .
 * Project：hlian health.lm.com.shop.adapter
 * Date：2019/8/13 14:40
 * Introduce：全部商会/影响力中心
 */
public class HLAllCompanyAdapter extends BaseQuickAdapter<HLAllCompanyEntity, BaseViewHolder> {
    public HLAllCompanyAdapter(@Nullable List<HLAllCompanyEntity> data) {
        super(R.layout.hl_activity_all_company_item, data);
    }

    /**
     * Implement this method and use the helper to adapt the view to the given item.
     *
     * @param helper A fully initialized helper.
     * @param item   The item that needs to be displayed.
     */
    @Override
    protected void convert(BaseViewHolder helper, HLAllCompanyEntity item) {
        ImageLoaderHelper.getInstance().load(mContext, item.getCompany_image(), helper.getView(R.id.imageView12));
        helper.setText(R.id.textView46, item.getCompany_name())
                .setText(R.id.textView49, item.getChairman())
                .setText(R.id.textView51, item.getMember() + "人")
                .setText(R.id.textView53, item.getPhone())
                .setText(R.id.textView55, item.getAddress())
                .addOnClickListener(R.id.textView47);
        TextView attention = helper.getView(R.id.textView47);
        if (item.getAttention().equals("1")) {
            attention.setBackground(ContextCompat.getDrawable(mContext, R.drawable.btn_theme));
            attention.setTextColor(ContextCompat.getColor(mContext, R.color.white));
            attention.setText("已关注");
        } else {
            attention.setBackground(ContextCompat.getDrawable(mContext, R.drawable.btn_theme_line));
            attention.setTextColor(ContextCompat.getColor(mContext, R.color.color_4a9bf7));
            attention.setText("关注");
        }
    }
}
